package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Name  string  `gorm:"type:varchar(10);not null;comment:商品名称"`
	Price float64 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	Stock int     `gorm:"type:int(5);not null;comment:商品数量"`
	Cover string  `gorm:"type:varchar(255);not null;comment:商品封面"`
}

func (g *Goods) Show(goodsId int) error {
	return Db.Where("id = ?", goodsId).Limit(1).Find(&g).Error
}
